package com.ycg.blog.controller;

import com.ycg.blog.common.PageView;
import com.ycg.blog.common.R;
import com.ycg.blog.pojo.vo.SimpleArticleVo;
import com.ycg.blog.pojo.vo.TagVo;
import com.ycg.blog.service.TagService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author YCG
 * @date 2024-03-06 14:34
 * @description 标签增删改
 */
@RestController
@RequestMapping("tags")
public class TagController {

    @Resource
    private TagService tagService;

    @GetMapping("/list")
    public R<PageView<TagVo>> getTagList(Integer current, Integer pageSize) {
        return tagService.getTagList(current, pageSize);
    }

    @GetMapping("/getArticles")
    public R<List<SimpleArticleVo>> getArticles(Integer tagId) {
        return tagService.getArticles(tagId);
    }

    @PutMapping("/put")
    public R<String> updateTagName(Integer tagId, String newName) {
        return tagService.updateTagName(tagId, newName);
    }

    @DeleteMapping("/delete")
    public R<String> deleteTagById(Integer tagId) {
        return tagService.deleteTagById(tagId);
    }
}
